package restaurant;

import java.util.Date;

/**
 * The Command object to update an offer.
 * 
 * @author Odessa
 */

public class cmdUpdateOffer implements Command
{

	/** The information aggregator. */
	private InformationAggregator info;

	/** The offer number of the offer being updated. */
	private int offerNo;

	/** The new start date of the offer. */
	private Date start;

	/** The new end date of the offer. */
	private Date end;

	/** The new description of the offer. */
	private String description;

	/** The new discount provided by the offer. */
	private double discount;



	/**
	 * Instantiates a new update offer command.
	 * 
	 * @param info the information aggregator.
	 * @param offerNo the offer number of the offer being updated.
	 * @param start the new start date of the offer.
	 * @param end the new end date of the offer.
	 * @param description the new description of the offer.
	 * @param discount the new discount of the offer.
	 */
	public cmdUpdateOffer(InformationAggregator info, int offerNo, Date start,
			Date end, String description, double discount) {
		this.info = info;
		this.offerNo = offerNo;
		this.start = start;
		this.end = end;
		this.description = description;
		this.discount = discount;
	}



	/**
	 * Updates an offer.
	 * 
	 * @return the updated offer.
	 * @see restaurant.Command#execute()
	 */
	@Override
	public Object execute()
	{
		SpecialOffers offers = info.getOffers();
		Offer updatedOffer = offers.updateOffer(offerNo, start, end,
				description, discount);

		return updatedOffer;
	}

}
